<header id="topbar" class="affix">
    <div class="topbar-left">
        <ol class="breadcrumb">
            <li class="crumb-active">
                <a href="<%= window.location.href %>">活动模板详情</a>
            </li>
            <li class="crumb-link">
                <a href="#op/template/">活动模板管理</a>
            </li>
            <li class="crumb-trail">模板编辑</li>
        </ol>
    </div>
    <div class="pull-right">
        <a href="javascript:;" class="btn btn-primary btn-sm light fw600 ml10 template-save"><span class="fa fa-save"></span>保存</a>
    </div>
</header>
<section id="content">
    <div class="panel">
        <div class="panel-heading">
            <span class="panel-icon"><i class="fa fa-gear text-primary"></i>
            </span>
            <span class="panel-title">参数设置</span>
        </div>
        <div class="panel-body">
            <form id="template-form" class="form-horizontal">
                <div class="form-group">
                    <label for="inputName" class="col-md-1 control-label">商品活动名称：</label>
                    <div class="col-md-9">
                        <input type="text" id="inputName" class="form-control" value="<%= info.name %>" placeholder="请输入活动名称..." required>
                    </div>
                </div>
                <div class="form-group">
                    <label for="inputShortName" class="col-md-1 control-label">商品活动简称：</label>
                    <div class="col-md-9">
                        <input type="text" maxlength="50" id="inputShortName" class="form-control" value="<%= info.short_title %>" placeholder="请输入活动简称...">
                    </div>
                </div>
                <div class="form-group">
                    <label class="col-md-1 control-label" for="inputDesc">商品活动描述：</label>
                    <div class="col-md-9">
                        <textarea class="form-control" id="inputDesc" rows="3"><%= info.desc %></textarea>
                    </div>
                </div>
                <div class="form-group">
                    <label for="inputGoodsId" class="col-md-1 control-label">
                        <a id="goodsLink" href="<%= info.goods_id ? ('#goods/' + info.goods_id + '/') : 'javascript:;' %>">对应商品：</a>
                    </label>
                    <div class="col-md-4">
                        <select class="required form-control search-select" id="inputGoodsId">
                            <% if(!info.goods_id){ %>
                                <option value="-1">请选择</option>
                            <% } %>
                            <% _.each(goodsList, function(goods){ %>
                                <option value="<%= goods.id %>" <%= info.goods_id == goods.id ? 'selected' : '' %>><%= goods.name %></option>
                            <% }) %>
                        </select>
                    </div>
                </div>
                <div class="form-group">
                    <label for="inputCategory" class="col-md-1 control-label">活动分类：</label>
                    <div class="col-md-4">
                        <select class="required form-control search-select" id="inputCategory" multiple="multiple">
                            <% _.each(categorys, function(category){ %>
                                <option value="<%= category.id %>" <%= info.category_ids.indexOf(category.id) >= 0 ? 'selected' : '' %>><%= category.name %></option>
                            <% }) %>
                        </select>
                    </div>
                    <label for="inputPK" class="col-md-1 control-label">活动模式:</label>
                    <div class="col-md-4">
                        <select id="inputPK" class="form-control">
                            <option value="0" <%= info.pk == 0 ? "selected" : '' %>>普通模式</option>
                            <option value="2" <%= info.pk == 2 ? "selected" : '' %>>2人PK</option>
                            <option value="3" <%= info.pk == 3 ? "selected" : '' %>>3人PK</option>
                        </select>
                    </div>
                </div>
                <div class="form-group">
                    <label for="inputUnit" class="col-md-1 control-label">购买单位：</label>
                    <div class="col-md-4">
                        <div class="input-group">
                            <span class="input-group-addon"><i class="fa fa-level-up"></i>
                            </span>
                            <input id="inputUnit" type="number" min="1" class="form-control" value="<%= info.unit %>" required>
                        </div>
                    </div>
                    <label for="inputTargetAmount" class="col-md-1 control-label">目标筹集次数：</label>
                    <div class="col-md-4">
                        <div class="input-group">
                            <span class="input-group-addon"><i class="fa fa-level-up"></i>
                            </span>
                            <input id="inputTargetAmount" type="number" min="0" class="form-control" value="<%= info.target_amount %>" />
                        </div>
                    </div>
                </div>
                <div class="form-group">
                    <label for="inputWeight" title="0 ~ 1000" class="col-md-1 control-label">活动权重：</label>
                    <div class="col-md-4">
                        <div class="input-group">
                            <span class="input-group-addon"><i class="fa fa-level-up"></i>
                            </span>
                            <input id="inputWeight" type="number" min="0" max="1000" class="form-control" value="<%= info.weight %>" required>
                        </div>
                    </div>
                    <label for="inputPrice" class="col-md-1 control-label">货币单价：</label>
                    <div class="col-md-4">
                        <div class="input-group">
                            <span class="input-group-addon"><i class="fa fa-usd"></i>
                            </span>
                            <input id="inputPrice" type="number" min="0" class="form-control" value="<%= info.price %>" required>
                        </div>
                    </div>
                </div>
                <div class="form-group">
                    <abbr title="0表示无限制">
                        <label for="inputBuyLimit" class="col-md-1 control-label">购买限制：</label>
                    </abbr>
                    <div class="col-md-4">
                        <div class="input-group">
                            <span class="input-group-addon"><i class="fa fa-level-up"></i>
                            </span>
                            <input id="inputBuyLimit" type="number" min="0" class="form-control" value="<%= info.buy_limit || 0 %>" required>
                        </div>
                    </div>
                    <label class="col-md-1 control-label">活动当前期数：</label>
                    <div class="col-md-4">
                        <p class="form-control-static text-muted">
                            <%= info.current_term %>
                        </p>
                    </div>
                </div>
                <div class="form-group">
                    <label for="inputStatus" class="col-md-1 control-label">活动状态：</label>
                    <div class="col-md-4">
                        <select id="inputStatus" class="form-control">
                            <option value="0" <%= info.status == 0 ? 'selected' : '' %>>待开始</option>
                            <option value="1" <%= info.status == 1 ? 'selected' : '' %>>进行中</option>
                            <option value="2" <%= info.status == 2 ? 'selected' : '' %>>已暂停</option>
                        </select>
                    </div>
                    <label for="inputCountry" class="col-md-1 control-label">面向国家：</label>
                    <div class="col-md-4">
                        <select class="form-control" id="inputCountry">
                            <option value="cn" <%= info.country == 'cn' ? 'selected' : '' %>>中国</option>
                            <option value="vn" <%= info.country == 'vn' ? 'selected' : '' %>>越南</option>
                        </select>
                    </div>
                </div>
            </form>
        </div>
    </div>

    <!-- manage cover -->
    <div class="panel">
        <div class="panel-heading">
            <span class="panel-icon"><i class="fa fa-gear text-primary"></i>
            </span>
            <span class="panel-title">封面管理</span>
            <span class="panel-controls">
                <button class="btn btn-alert" id="uploadCover" data-img="cover">上传封面</button>
            </span>
        </div>
        <div class="panel-body">
            <div class="row">
                <% if(info.cover){ %>
                <div class="col-lg-3 col-md-4 col-xs-6 thumb">
                    <a class="close delete-image" href="#" style="display: none">x</a>
                    <a class="thumbnail image-popup" href=<%= info.cover %>>
                    <img id="cover" src=<%= info.cover %>>
                </a>
                </div>
                <% } %>
            </div>
        </div>
    </div>
    <!-- manage pics -->
    <div class="panel">
        <div class="panel-heading">
            <span class="panel-icon"><i class="fa fa-gear text-primary"></i>
            </span>
            <span class="panel-title">图片管理</span>
            <span class="panel-controls">
                <button class="btn btn-alert btn-upload" id="uploadCovers">上传图片</button>
            </span>
        </div>
        <div class="panel-body" id="covers">
            <div class="row sortable">
                <% var imageList = info.images.split(','); %>
                    <% _.each(imageList, function(url, index){ %>
                        <div class="col-lg-3 col-md-4 col-xs-6 thumb">
                            <a class="close delete-image" href="#" style="display: none">x</a>
                            <a class="thumbnail image-popup" href=<%= url %>>
                            <img src=<%= url %>>
                        </a>
                        </div>
                        <% }) %>
            </div>
        </div>
    </div>
    <!-- manage graphics -->
    <div class="panel">
        <div class="panel-heading">
            <span class="panel-icon"><i class="fa fa-gear text-primary"></i>
            </span>
            <span class="panel-title">图文详情管理</span>
            <span class="panel-controls">
                <button class="btn btn-alert btn-upload" id="uploadGraphics">上传图文详情</button>
            </span>
        </div>
        <div class="panel-body" id="graphics">
            <div class="row sortable">
                <% var graphicsList = info.graphics.split(','); %>
                    <% _.each(graphicsList, function(url, index){ %>
                        <div class="col-lg-3 col-md-4 col-xs-6 thumb">
                            <a class="close delete-image" href="#" style="display: none">x</a>
                            <a class="thumbnail image-popup" href=<%= url %>>
                            <img src=<%= url %>>
                        </a>
                        </div>
                        <% }) %>
            </div>
        </div>
    </div>

    <!-- Panel popup -->
    <div id="uploadImagePanel" class="popup-basic popup-lg bg-none mfp-with-anim mfp-hide">
        <div class="panel">
            <div class="panel-heading">
                <span class="panel-icon"><i class="fa fa-pencil"></i></span>
                <span class="panel-title">上传图片</span>
            </div>
            <div class="panel-body">
                <h3 class="mt5">单个图片最好不要超过4M</h3>
                <div class="col-md-10">
                    <div id="container">
                        <a class="btn btn-default btn-lg" id="pickfiles" href="#">
                            <i class="glyphicon glyphicon-plus"></i>
                            <span>选择文件</span>
                        </a>
                    </div>
                </div>
                <div style="margin-top:40px;display:none" id="success" class="col-md-10">
                    <div class="alert-success">
                        队列全部文件处理完毕
                    </div>
                </div>
                <div class="col-md-10">
                    <table class="table table-striped table-hover text-left" id="processTable" style="margin-top:40px;display:none">
                        <thead>
                            <tr>
                                <th class="col-md-3">thumb</th>
                                <th class="col-md-2">size</th>
                                <th class="col-md-3">link</th>
                            </tr>
                        </thead>
                        <tbody id="fsUploadProgress">
                        </tbody>
                    </table>
                </div>
            </div>
            <div class="panel-footer text-right">
                <button class="btn btn-primary" type="button" id="addCachedImgs">确定</button>
            </div>
        </div>
    </div>
</section>
